<template>
  <div class="tab-container">
    <!-- 头部区域：图标+标题+Tab切换 -->
    <div class="header-container">
      <div class="title-section">
        <img src="@/assets/imgs/big_vip/icons/hot_icon.png" alt="热门" class="hot-icon">
        <h3>热门电影推荐</h3>
      </div>

      <div class="tab-header">
        <div v-for="(tab, index) in tabs" :key="index" class="tab-item" :class="{ active: activeTab === index }"
          @click="activeTab = index">
          {{ tab.label }}
        </div>
        <div class="tab-indicator" :style="indicatorStyle"></div>
      </div>
    </div>

    <!-- 内容区域 -->
    <div class="tab-content">
      <!-- 电影内容 -->
      <div v-show="activeTab === 0" class="content-section">
        <div class="content-grid">
          <div v-for="(movie, idx) in movies" :key="idx" class="content-item">
            <img :src="movie.poster" :alt="movie.title">
            <p>{{ movie.title }}</p>
            <span class="rating">{{ movie.rating }}</span>
          </div>
        </div>
      </div>

      <!-- 电视剧内容 -->
      <div v-show="activeTab === 1" class="content-section">
        <div class="content-grid">
          <div v-for="(watch, idx) in watches" :key="idx" class="content-item">
            <img :src="watch.cover" :alt="watch.title">
            <p>{{ watch.title }}</p>
            <span class="rating">{{ watch.rating }}</span>
          </div>
        </div>
      </div>

      <!-- 综艺内容 -->
      <div v-show="activeTab === 2" class="content-section">
        <div class="content-grid">
          <div v-for="(movie, idx) in movies" :key="idx" class="content-item">
            <img :src="movie.poster" :alt="movie.title">
            <p>{{ movie.title }}</p>
            <span class="rating">{{ movie.rating }}</span>
          </div>
        </div>
      </div>
      <!-- 国创 -->
      <div v-show="activeTab === 3" class="content-section">
        <div class="content-grid">
          <div v-for="(movie, idx) in movies" :key="idx" class="content-item">
            <img :src="movie.poster" :alt="movie.title">
            <p>{{ movie.title }}</p>
            <span class="rating">{{ movie.rating }}</span>
          </div>
        </div>
      </div>
      <!-- 电视剧内容 -->
      <div v-show="activeTab === 4" class="content-section">
        <div class="content-grid">
          <div v-for="(movie, idx) in movies" :key="idx" class="content-item">
            <img :src="movie.poster" :alt="movie.title">
            <p>{{ movie.title }}</p>
            <span class="rating">{{ movie.rating }}</span>
          </div>
        </div>
      </div>
      <!-- 纪录片 -->
      <div v-show="activeTab === 5" class="content-section">
        <div class="content-grid">
          <div v-for="(movie, idx) in movies" :key="idx" class="content-item">
            <img :src="movie.poster" :alt="movie.title">
            <p>{{ movie.title }}</p>
            <span class="rating">{{ movie.rating }}</span>
          </div>
        </div>
      </div>
      <!-- 综艺内容 -->
      <div v-show="activeTab === 6" class="content-section">
        <div class="content-grid">
          <div v-for="(movie, idx) in movies" :key="idx" class="content-item">
            <img :src="movie.poster" :alt="movie.title">
            <p>{{ movie.title }}</p>
            <span class="rating">{{ movie.rating }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';
import img1 from '@/assets/imgs/big_vip/card_img1.png';
import img2 from '@/assets/imgs/big_vip/card_img2.png';
// Tab数据
const tabs = ref([
  { label: '会员' },
  { label: '番剧' },
  { label: '电影' },
  { label: '国创' },
  { label: '电视剧' },
  { label: '纪录片' },
  { label: '综艺' }
]);

const activeTab = ref(0);

// 电影数据
const movies = ref([
  { title: '流浪地球2', poster: img1, rating: '9.2' },
  { title: '满江红', poster: img1, rating: '8.5' },
  { title: '深海', poster: img1, rating: '9.0' },
  { title: '无名', poster: img1, rating: '8.7' },
  { title: '深海', poster: img1, rating: '9.0' },
  { title: '无名', poster: img1, rating: '8.7' }
]);

// 电视剧数据
const watches = ref([
  { title: '狂飙', cover: img2, episode: '全39集', views: '5.2亿次播放' },
  { title: '三体', cover: img2, episode: '全30集', views: '3.8亿次播放' },
  { title: '去有风的地方', cover: img2, episode: '全40集', views: '4.1亿次播放' },
  { title: '狂飙', cover: img2, episode: '全39集', views: '5.2亿次播放' },
  { title: '三体', cover: img2, episode: '全30集', views: '3.8亿次播放' },
  { title: '去有风的地方', cover: img2, episode: '全40集', views: '4.1亿次播放' }
]);

// // 综艺数据
// const featuredShow = ref({
//   title: '奔跑吧·共同富裕篇',
//   poster: img1,
//   description: '兄弟团走进浙江乡村，展现共同富裕示范区建设成果'
// });

// const shows = ref([
//   { name: '一年一度喜剧大赛2', thumbnail: img1 },
//   { name: '无限超越班', thumbnail: img1 },
//   { name: '我们的歌4', thumbnail: img1 }
// ]);

// 计算指示器位置
const indicatorStyle = computed(() => ({
  width: `${100 / tabs.value.length}%`,
  left: `${activeTab.value * (100 / tabs.value.length)}%`
}));
</script>

<style scoped lang="scss">
.tab-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  // padding: 20px 0;

  /* 头部容器样式 */
  .header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 0 15px;

    .title-section {
      display: flex;
      align-items: center;
      gap: 12px;

      .hot-icon {
        width: 32px;
        height: 32px;
        object-fit: contain;
      }

      h3 {
        font-size: 22px;
        color: #333;
        margin: 0;
        font-weight: 600;
        line-height: 1.2;
      }
    }
  }

  /* Tab切换样式 */
  .tab-header {
    display: flex;
    position: relative;
    right: 30%;

    .tab-item {
      padding: 12px 25px;
      font-size: 16px;
      color: #666;
      cursor: pointer;
      transition: all 0.3s ease;
      font-weight: 500;
      white-space: nowrap;

      &:hover {
        color: #ff4e4e;
      }

      &.active {
        color: #ff4e4e;
        font-weight: 600;
      }
    }

    .tab-indicator {
      position: absolute;
      bottom: -1px;
      height: 3px;
      background: #ff4e4e;
      transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    }
  }

  /* 内容区域 */
  .tab-content {
    padding: 20px 0;
    min-height: 400px;

    .content-section {
      .content-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 20px;
        padding: 0 10px;

        .content-item {
          background: #fff;
          overflow: hidden;
          transition: transform 0.3s;

          &:hover {
            transform: translateY(-5px);
          }

          img {
            width: 100%;
            height: 250px;
            object-fit: cover;
            border-radius: 4px;
          }

          p {
            padding: 10px 5px 0;
            font-size: 14px;
            margin: 0;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }

          .rating {
            display: block;
            padding: 5px;
            color: #ff4e4e;
            font-weight: bold;
            font-size: 13px;
          }
        }
      }

      /* 电视剧列表样式 */
      .content-list {
        .list-item {
          display: flex;
          align-items: center;
          padding: 12px;
          background: #fff;
          margin-bottom: 10px;
          border-radius: 6px;
          transition: all 0.3s;

          &:hover {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
          }

          .rank {
            font-size: 18px;
            font-weight: bold;
            color: #ff4e4e;
            width: 30px;
            text-align: center;
          }

          img {
            width: 80px;
            height: 100px;
            object-fit: cover;
            border-radius: 4px;
            margin-right: 15px;
          }

          .info {
            flex: 1;

            .title {
              font-size: 16px;
              margin: 0 0 5px;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
            }

            .meta {
              font-size: 12px;
              color: #999;
              margin: 0;
            }
          }
        }
      }

      /* 综艺内容样式 */
      .show-banner {
        display: flex;
        background: linear-gradient(135deg, #ff4e4e, #ff8e8e);
        border-radius: 8px;
        overflow: hidden;
        margin-bottom: 20px;
        color: white;

        img {
          width: 40%;
          object-fit: cover;
        }

        .show-info {
          padding: 20px;
          flex: 1;

          h4 {
            font-size: 20px;
            margin: 0 0 10px;
          }

          p {
            font-size: 14px;
            opacity: 0.9;
            margin-bottom: 20px;
          }

          .play-btn {
            background: white;
            color: #ff4e4e;
            border: none;
            padding: 8px 20px;
            border-radius: 20px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;

            &:hover {
              transform: scale(1.05);
              box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            }
          }
        }
      }

      .show-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;

        .show-card {
          img {
            width: 100%;
            height: 100px;
            object-fit: cover;
            border-radius: 4px;
            margin-bottom: 8px;
          }

          p {
            font-size: 13px;
            margin: 0;
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }
        }
      }
    }
  }
}
</style>
